﻿using System;
using System.Timers;
using RxjhServer.DbClss;

namespace RxjhServer
{
    public class EvePVPClass : IDisposable
    {
        private System.Timers.Timer 时间1;

        private System.Timers.Timer 时间2;

        private System.Timers.Timer 时间3;

        private System.Timers.Timer 时间4;

        private System.Timers.Timer 时间5;

        private DateTime kssj;

        private DateTime kssjgj;

        private int kssjint;

        public Players PlayerA;

        public Players PlayerB;

        public string PVPName = string.Empty;

        private int PVPType;

        private int MapID;

        public ThreadSafeDictionary<int, Players> playlist = new ThreadSafeDictionary<int, Players>();
        //string[] dt = World.宣战区地图坐标.Split(',');

        public EvePVPClass(ThreadSafeDictionary<int, Players> players, int type)
        {
            try
            {
                this.kssj = DateTime.Now.AddMinutes(1.0);
                this.PVPType = type;
                foreach (Players current in players.Values)
                {
                    this.playlist.Add(current.人物全服ID, current);
                    if (this.PlayerA == null)
                    {
                        this.PlayerA = current;
                        this.PlayerA.PVP分数 = 0;
                        PlayerA.系统提示("宣战期间不能使用回城符、土灵符、追杀和传送命令等功能!", 10, "宣战规则");
                        PlayerA.系统提示("超出范围扣除一分!达到负10分则为输!宣战起间下线也算输!", 10, "宣战规则");
                        PlayerA.系统提示("此地图死亡掉落5000武勋,对方获得5000武勋!", 10, "宣战规则");
                        PlayerA.系统提示("反之谁先获得10分谁获胜!杀死对方10次!", 10, "宣战规则");
                        PlayerA.系统提示("获胜者获得对方2W武勋!!", 10, "宣战规则");
                        PlayerA.系统提示("失败惩罚减少打怪获得经验" + double.Parse(World.dt[6]) * 100 + "%", 10, "宣战规则");
                    }
                    else if (this.PlayerB == null)
                    {
                        this.PlayerB = current;
                        this.PlayerB.PVP分数 = 0;
                        PlayerB.系统提示("宣战期间不能使用回城符、土灵符、追杀和传送命令等功能!", 10, "宣战规则");
                        PlayerB.系统提示("超出范围扣除一分!达到负10分则为输!宣战起间下线也算输!", 10, "宣战规则");
                        PlayerB.系统提示("此地图死亡掉落5000武勋,对方获得5000武勋!", 10, "宣战规则");
                        PlayerB.系统提示("反之谁先获得10分谁获胜!杀死对方10次!", 10, "宣战规则");
                        PlayerA.系统提示("获胜者获得对方2W武勋!!", 10, "宣战规则");
                        PlayerB.系统提示("失败惩罚减少打怪获得经验" + double.Parse(World.dt[6]) * 100 + "%", 10, "宣战规则");
                    }
                }
                this.MapID = int.Parse(World.dt[0]);
                this.PVPName = "宣战区";
                World.宣战进程 = 2;
                this.时间1 = new System.Timers.Timer(60000.0);
                this.时间1.Elapsed += new ElapsedEventHandler(this.时间结束事件1);
                this.时间1.Enabled = true;
                this.时间1.AutoReset = true;
                this.时间结束事件1(null, null);
            }
            catch (Exception arg)
            {
                Form1.WriteLine(1, "PVP EveClass 出错：" + arg);
            }
        }

        public void 时间结束事件1(object source, ElapsedEventArgs e)
        {
            try
            {
                int num = (int)this.kssj.Subtract(DateTime.Now).TotalSeconds;
                ////if (num <= 0)
                ////{
                ////    if (this.PVPType == 80)
                ////    {
                ////        World.Eve80进程 = 2;
                ////    }
                ////    else if (this.PVPType == 90)
                ////    {
                ////        World.Eve90进程 = 2;
                ////    }
                ////    num = 0;
                ////}
                this.kssjint = num;
                foreach (Players current in World.allConnectedChars.Values)
                {
                    current.系统提示(string.Concat(new object[]
                    {
                        "[",
                        this.PlayerA.UserName,
                        "] 和 [",
                        this.PlayerB.UserName,
                        "]即将在",
                        this.PVPName,
                        "场宣战,",
                        this.kssjint,
                        "秒后计分。"
                    }), 19, this.PVPName);

                }
                if (this.kssjint <= 0)
                {
                    foreach (Players current2 in this.playlist.Values)
                    {
                        if (!current2.检查玩家是否在对练区内(current2))
                        {
                            current2.移动(float.Parse(World.dt[1]), float.Parse(World.dt[2]), 15f, int.Parse(World.dt[0]));
                            
                        }
                        current2.系统公告("开始计分...");
                    }
                    this.时间1.Enabled = false;
                    this.时间1.Close();
                    this.时间1.Dispose();
                    World.宣战进程 = 3;
                    this.kssjgj = DateTime.Now.AddMinutes(10.0);
                    this.时间2 = new System.Timers.Timer(10000.0);
                    this.时间2.Elapsed += new ElapsedEventHandler(this.时间结束事件2);
                    this.时间2.Enabled = true;
                    this.时间2.AutoReset = true;
                    this.时间5 = new System.Timers.Timer(3000.0);
                    this.时间5.Elapsed += new ElapsedEventHandler(this.时间结束事件5);
                    this.时间5.Enabled = true;
                    this.时间5.AutoReset = true;
                }
            }
            catch (Exception arg)
            {
                Form1.WriteLine(1, "PVP 时间结束事件1 出错：" + arg);
            }
        }

        public void 时间结束事件2(object source, ElapsedEventArgs e)
        {
            try
            {
                int num = (int)this.kssjgj.Subtract(DateTime.Now).TotalSeconds;
                foreach (Players current in this.playlist.Values)
                {
                    current.系统提示(string.Concat(new object[]
                    {
                        this.PlayerA.UserName,
                        "->[",
                        this.PlayerA.PVP分数,
                        "] VS ",
                        this.PlayerB.UserName,
                        "->[",
                        this.PlayerB.PVP分数,
                        "] 宣战结束倒计时",
                        num,
                        "秒。"
                    }), 19, this.PVPName);
                }
                if (num <= 0)
                {
                    World.宣战进程 = 6;
                    this.时间2.Enabled = false;
                    this.时间2.Close();
                    this.时间2.Dispose();
                    this.时间5.Enabled = false;
                    this.时间5.Close();
                    this.时间5.Dispose();
                    this.时间3 = new System.Timers.Timer(10000.0);
                    this.时间3.Elapsed += new ElapsedEventHandler(this.时间结束事件3);
                    this.时间3.Enabled = true;
                    this.时间3.AutoReset = false;
                }
            }
            catch (Exception arg)
            {
                Form1.WriteLine(1, "PVP 时间结束事件2 出错：" + arg);
            }
        }

        public void 时间结束事件3(object source, ElapsedEventArgs e)
        {
            try
            {
                //int num = (int)((double)(World.进场最低费用 * 2) * (1.0 - World.场地佣金百分比));
                if (!this.PlayerA.Client.Running && !this.PlayerB.Client.Running)
                {
                    foreach (Players current in World.allConnectedChars.Values)
                    {
                        current.系统提示("宣战时间到！由于双方中场退出,宣战比赛结束。", 19, this.PVPName);
                    }
                    this.Dispose();
                }
                else if (!this.PlayerA.Client.Running)
                {
                    foreach (Players current2 in World.allConnectedChars.Values)
                    {
                        current2.系统提示(string.Concat(new string[]
                        {
                            "宣战时间到！由于[",
                            this.PlayerA.UserName,
                            "]中场退出,[",
                            this.PlayerB.UserName,
                            "]获胜,宣战比赛结束。"
                        }), 19, this.PVPName);
                    }
                    Dispose();
                }
                else if (!this.PlayerB.Client.Running)
                {
                    foreach (Players current3 in World.allConnectedChars.Values)
                    {
                        current3.系统提示(string.Concat(new string[]
                        {
                            "宣战时间到！由于[",
                            this.PlayerB.UserName,
                            "]中场退出,[",
                            this.PlayerA.UserName,
                            "]获胜,宣战比赛结束。"
                        }), 19, this.PVPName);
                    }
                    Dispose();

                }
                else if (this.PlayerA.PVP分数 == this.PlayerB.PVP分数)
                {
                    foreach (Players current4 in World.allConnectedChars.Values)
                    {
                        current4.系统提示("宣战时间到,双方没有在时间内分出胜负,比分相等.均不受到惩罚。", 19, this.PVPName);
                    }
                    Dispose();

                }
                else if (this.PlayerA.PVP分数 > this.PlayerB.PVP分数)
                {
                    //this.PlayerA.查百宝阁元宝数();
                    //this.PlayerA.检察元宝数据(num, 1);
                    //this.PlayerA.保存元宝数据();
                    //RxjhClass.百宝记录(this.PlayerA.Userid, this.PlayerA.UserName, 0L, "宣战胜利获得", 1, num);
                    foreach (Players current4 in World.allConnectedChars.Values)
                    {
                        current4.系统提示(string.Concat(new object[]
                        {
                            "宣战时间到,[",
                            this.PlayerA.UserName,
                            "][",
                            this.PlayerA.PVP分数,
                            "] VS [",
                            this.PlayerB.UserName,
                            "][",
                            this.PlayerB.PVP分数,
                            "] 。"
                        }), 19, this.PVPName);
                        current4.系统提示("[" + this.PlayerA.UserName + "]获胜,宣战比赛结束。", 19, this.PVPName);
                    }
                    int num2 = 60000 * int.Parse(World.dt[5]);//时间
                    if (PlayerB.追加状态列表.ContainsKey(int.Parse(World.dt[4])))
                    {
                        追加状态类 追加状态类 = PlayerB.追加状态列表[int.Parse(World.dt[4])];
                        //num2 += 追加状态类.FLD_sj;
                        追加状态类.时间结束事件();
                    }
                    if (PlayerB.追加状态列表.ContainsKey(int.Parse(World.fc[4])))
                    {
                        追加状态类 追加状态类 = PlayerB.追加状态列表[int.Parse(World.fc[4])];
                        //num2 += 追加状态类.FLD_sj;
                        追加状态类.时间结束事件();
                    }


                    追加状态类 追加状态类2 = new 追加状态类(PlayerB, num2, int.Parse(World.dt[4]), 1);
                    PlayerB.追加状态列表.Add(追加状态类2.FLD_PID, 追加状态类2);
                    PlayerB.FLD_人物_复仇_经验百分比 = double.Parse(World.dt[6]);
                    PlayerB.状态效果(BitConverter.GetBytes(int.Parse(World.dt[4])), 1, num2);
                    bool 是否满足 = false;
                    if (PlayerB.Player_WuXun >= 20000)
                    {
                        是否满足 = true;
                        PlayerB.Player_WuXun -= 20000;
                        PlayerA.Player_WuXun += 20000;
                        PlayerA.更新武功和状态();
                        //PlayerA.保存人物的数据();
                        PlayerA.系统提示("获胜获得2W武勋, 宣战胜利。", 19, this.PVPName);
                        PlayerB.系统提示("战败获得惩罚打怪获得经验降低" + double.Parse(World.dt[6]) * 100 + " %,减少2W武勋, 宣战比赛结束。", 19, this.PVPName);
                    }
                    PlayerB.更新武功和状态();
                    //PlayerB.保存人物的数据();
                    if (!是否满足)
                    {
                        PlayerB.系统提示("战败获得惩罚打怪获得经验降低" + double.Parse(World.dt[6]) * 100 + " %, 宣战比赛结束。", 19, this.PVPName);
                    }
                    Dispose();

                }
                else if (this.PlayerA.PVP分数 < this.PlayerB.PVP分数)
                {
                    //this.PlayerA.查百宝阁元宝数();
                    //this.PlayerA.检察元宝数据(num, 1);
                    //this.PlayerA.保存元宝数据();
                    //RxjhClass.百宝记录(this.PlayerA.Userid, this.PlayerA.UserName, 0L, "宣战胜利获得", 1, num);
                    foreach (Players current4 in World.allConnectedChars.Values)
                    {
                        current4.系统提示(string.Concat(new object[]
                        {
                            "宣战时间到,[",
                            this.PlayerA.UserName,
                            "][",
                            this.PlayerA.PVP分数,
                            "] VS [",
                            this.PlayerB.UserName,
                            "][",
                            this.PlayerB.PVP分数,
                            "] 。"
                        }), 19, this.PVPName);
                        current4.系统提示("[" + this.PlayerB.UserName + "]获胜,宣战比赛结束。", 19, this.PVPName);
                    }
                    int num2 = 60000 * int.Parse(World.dt[5]);//时间
                    if (PlayerA.追加状态列表.ContainsKey(int.Parse(World.dt[4])))
                    {
                        追加状态类 追加状态类 = PlayerA.追加状态列表[int.Parse(World.dt[4])];
                        //num2 += 追加状态类.FLD_sj;
                        追加状态类.时间结束事件();
                    }
                    if (PlayerA.追加状态列表.ContainsKey(int.Parse(World.fc[4])))
                    {
                        追加状态类 追加状态类 = PlayerA.追加状态列表[int.Parse(World.fc[4])];
                        //num2 += 追加状态类.FLD_sj;
                        追加状态类.时间结束事件();
                    }
                    追加状态类 追加状态类2 = new 追加状态类(PlayerA, num2, int.Parse(World.dt[4]), 1);
                    PlayerA.追加状态列表.Add(追加状态类2.FLD_PID, 追加状态类2);
                    PlayerA.FLD_人物_复仇_经验百分比 = double.Parse(World.dt[6]);
                    PlayerA.状态效果(BitConverter.GetBytes(int.Parse(World.dt[4])), 1, num2);
                    bool 是否满足 = false;
                    if (PlayerA.Player_WuXun >= 20000)
                    {
                        是否满足 = true;
                        PlayerA.Player_WuXun -= 20000;
                        PlayerB.Player_WuXun += 20000;
                        PlayerB.更新武功和状态();
                        //PlayerB.保存人物的数据();
                        PlayerB.系统提示("获胜获得2W武勋, 宣战胜利。", 19, this.PVPName);
                        PlayerA.系统提示("战败获得惩罚打怪获得经验降低" + double.Parse(World.dt[6]) * 100 + " %减少2W武勋, 宣战比赛结束。", 19, this.PVPName);
                    }
                    PlayerA.更新武功和状态();
                    //PlayerA.保存人物的数据();
                    if (!是否满足)
                    {
                        PlayerA.系统提示("战败获得惩罚打怪获得经验降低" + double.Parse(World.dt[6]) * 100 + " %, 宣战比赛结束。", 19, this.PVPName);
                    }
                    Dispose();

                }

                World.宣战进程 = 5;
                this.kssjgj = DateTime.Now.AddMinutes(1.0);
                this.时间3.Enabled = false;
                this.时间3.Close();
                this.时间3.Dispose();
                this.时间4 = new System.Timers.Timer(30000.0);
                this.时间4.Elapsed += new ElapsedEventHandler(this.时间结束事件4);
                this.时间4.Enabled = true;
                this.时间4.AutoReset = true;
                this.时间5.Enabled = false;
                this.时间5.Close();
                this.时间5.Dispose();
            }
            catch (Exception arg)
            {
                this.Dispose();
                Form1.WriteLine(1, "PVP 时间结束事件3 出错：" + arg);
            }
        }
        public void 时间结束事件4(object source, ElapsedEventArgs e)
        {
            try
            {
                int num = (int)this.kssjgj.Subtract(DateTime.Now).TotalSeconds;
                if (num <= 0)
                {
                    this.时间4.Enabled = false;
                    this.时间4.Close();
                    this.时间4.Dispose();
                    World.宣战进程 = 4;
                    this.Dispose();
                }
            }
            catch (Exception arg)
            {
                this.Dispose();
                Form1.WriteLine(1, "PVP 时间结束事件4 出错：" + arg);
            }
        }
        public void 时间结束事件5(object source, ElapsedEventArgs e)
        {
            try
            {
                foreach (Players current in this.playlist.Values)
                {
                    if (current.人物PK模式 != 2)
                    {
                        current.切换PK模式(2);
                    }
                    if (!current.检查玩家是否在对练区内(current))
                    {
                        current.移动(float.Parse(World.dt[1]), float.Parse(World.dt[2]), 15f,int.Parse( World.dt[0]));
                        //if (current.PVP分数 >= 0)
                        //{
                            current.PVP分数--;
                            current.系统提示("你已累计逃跑一次,扣除一分。累计负10分后,视为输!", 19, "系統警告");
                        //}
                        break;
            
                    }
                    else
                    {
                        if (current.PVP分数 <= -5)
                        {
                            if (current == PlayerA && PlayerA != null)
                            {

                                int num2 = 60000 * int.Parse(World.dt[5]);//时间
                                if (PlayerA.追加状态列表.ContainsKey(int.Parse(World.dt[4])))
                                {
                                    追加状态类 追加状态类 = PlayerA.追加状态列表[int.Parse(World.dt[4])];
                                    //num2 += 追加状态类.FLD_sj;
                                    追加状态类.时间结束事件();
                                }
                                if (PlayerA.追加状态列表.ContainsKey(int.Parse(World.fc[4])))
                                {
                                    追加状态类 追加状态类 = PlayerA.追加状态列表[int.Parse(World.fc[4])];
                                    //num2 += 追加状态类.FLD_sj;
                                    追加状态类.时间结束事件();
                                }
                                追加状态类 追加状态类2 = new 追加状态类(PlayerA, num2, int.Parse(World.dt[4]), 1);
                                PlayerA.追加状态列表.Add(追加状态类2.FLD_PID, 追加状态类2);
                                PlayerA.FLD_人物_复仇_经验百分比 = double.Parse(World.dt[6]);
                                PlayerA.状态效果(BitConverter.GetBytes(int.Parse(World.dt[4])), 1, num2);
                                bool 是否满足 = false;
                                if (PlayerA.Player_WuXun >= 20000)
                                {
                                    是否满足 = true;
                                    PlayerA.Player_WuXun -= 20000;
                                    PlayerB.Player_WuXun += 20000;
                                    PlayerB.更新武功和状态();
                                    //PlayerB.保存人物的数据();
                                    PlayerB.系统提示("获胜获得2W武勋, 宣战胜利。", 19, this.PVPName);
                                    PlayerA.系统提示("累计逃跑次数10次,打怪获得经验降低" + double.Parse(World.dt[6]) * 100 + " %减少2W武勋, 宣战失败。", 19, this.PVPName);
                                }
                                PlayerA.更新武功和状态();
                                //PlayerA.保存人物的数据();
                                if (!是否满足)
                                {
                                    PlayerA.系统提示("累计逃跑次数10次,打怪获得经验降低" + double.Parse(World.dt[6]) * 100 + " %, 宣战失败。", 19, this.PVPName);
                                }
                                World.conn.发送("全服公告|6|系统提示|宣战结束[" + this.PlayerB.UserName + "]获胜,宣战比赛结束。");
                                Dispose();
                            }
                            else if (current == PlayerB && PlayerB != null)
                            {

                                int num2 = 60000 * int.Parse(World.dt[5]);//时间
                                if (PlayerB.追加状态列表.ContainsKey(int.Parse(World.dt[4])))
                                {
                                    追加状态类 追加状态类 = PlayerB.追加状态列表[int.Parse(World.dt[4])];
                                    //num2 += 追加状态类.FLD_sj;
                                    追加状态类.时间结束事件();
                                }
                                追加状态类 追加状态类2 = new 追加状态类(PlayerB, num2, int.Parse(World.dt[4]), 1);
                                PlayerB.追加状态列表.Add(追加状态类2.FLD_PID, 追加状态类2);
                                PlayerB.FLD_人物_复仇_经验百分比 = double.Parse(World.dt[6]);
                                PlayerB.状态效果(BitConverter.GetBytes(int.Parse(World.dt[4])), 1, num2);
                                bool 是否满足 = false;
                                if (PlayerB.Player_WuXun >= 20000)
                                {
                                    是否满足 = true;
                                    PlayerB.Player_WuXun -= 20000;
                                    PlayerA.Player_WuXun += 20000;
                                    PlayerA.更新武功和状态();
                                    //PlayerA.保存人物的数据();
                                    PlayerA.系统提示("获胜获得2W武勋, 宣战胜利。", 19, this.PVPName);
                                    PlayerB.系统提示("累计逃跑次数10次,打怪获得经验降低" + double.Parse(World.dt[6]) * 100 + " %,减少2W武勋, 宣战失败。", 19, this.PVPName);
                                }
                                PlayerB.更新武功和状态();
                                //PlayerB.保存人物的数据();
                                if (!是否满足)
                                {
                                    PlayerB.系统提示("累计逃跑次数10次,打怪获得经验降低" + double.Parse(World.dt[6]) * 100 + " %, 宣战失败。", 19, this.PVPName);
                                }
       
                                World.conn.发送("全服公告|6|系统提示|宣战结束[" + this.PlayerA.UserName + "]获胜,宣战比赛结束。");
                                Dispose();
                            }

                            break;

                        }
                       
                    }
                }

                //foreach (Players current2 in World.allConnectedChars.Values)
                //{
                //    if (current2.人物坐标_地图 == this.MapID && current2.人物全服ID != this.PlayerA.人物全服ID && current2.人物全服ID != this.PlayerB.人物全服ID)
                //    {
                       
                //        current2.移动(529f, 1528f, 15f, 101);
                //    }
                //}
            }
            catch (Exception arg)
            {
                this.Dispose();
                Form1.WriteLine(1, "PVP 时间结束事件6 出错：" + arg);
            }
        }

        public void Dispose()
        {
            try
            {

                if (this.时间1 != null)
                {
                    this.时间1.Enabled = false;
                    this.时间1.Close();
                    this.时间1.Dispose();
                }
                if (this.时间2 != null)
                {
                    this.时间2.Enabled = false;
                    this.时间2.Close();
                    this.时间2.Dispose();
                }
                if (this.时间3 != null)
                {
                    this.时间3.Enabled = false;
                    this.时间3.Close();
                    this.时间3.Dispose();
                }
                if (this.时间4 != null)
                {
                    this.时间4.Enabled = false;
                    this.时间4.Close();
                    this.时间4.Dispose();
                }
                if (this.时间5 != null)
                {
                    this.时间5.Enabled = false;
                    this.时间5.Close();
                    this.时间5.Dispose();
                }
                foreach (Players current in this.playlist.Values)
                {
                    current.PVP分数 = 0;
                    current.移动(529f, 1528f, 15f, 101);
                    current.切换PK模式(0);
                }
                this.PlayerA = null;
                this.PlayerB = null;
                this.playlist.Clear();
                World.eve90Players.Clear();
            }
            catch
            {
                this.PlayerA = null;
                this.PlayerB = null;
                World.eve90Players.Clear();
                this.playlist.Clear();
            }
            finally
            {
                this.PlayerA = null;
                this.PlayerB = null;
                World.eve90Players.Clear();
                this.playlist.Clear();
            }
            World.宣战 = null;
            World.宣战进程 = 0;
        }
    }

    public class EveFCClass : IDisposable
    {
        private System.Timers.Timer 时间1;

        private System.Timers.Timer 时间2;

        private System.Timers.Timer 时间3;

        private System.Timers.Timer 时间4;

        private System.Timers.Timer 时间5;

        private DateTime kssj;

        private DateTime kssjgj;

        private int kssjint;

        public Players PlayerA;

        public Players PlayerB;

        public string PVPName = string.Empty;

        private int PVPType;

        private int MapID;

        public ThreadSafeDictionary<int, Players> playlist = new ThreadSafeDictionary<int, Players>();
        //string[] dt = World.复仇区地图坐标.Split(',');

        public EveFCClass(ThreadSafeDictionary<int, Players> players, int type)
        {
            try
            {
                this.kssj = DateTime.Now.AddMinutes(1.0);
                this.PVPType = type;
                foreach (Players current in players.Values)
                {
                    this.playlist.Add(current.人物全服ID, current);
                    if (this.PlayerA == null)
                    {
                        this.PlayerA = current;
                        this.PlayerA.FC分数 = 0;
                        PlayerA.系统提示("复仇期间不能使用回城符、土灵符、追杀和传送命令等功能!", 10, "复仇规则");
                        PlayerA.系统提示("超出范围扣除一分!达到负10分则为输!复仇起间下线也算输!", 10, "复仇规则");
                        PlayerA.系统提示("此地图死亡掉落5000武勋,对方获得5000武勋!", 10, "复仇规则");
                        PlayerA.系统提示("反之谁先获得10分谁获胜!杀死对方10次!", 10, "复仇规则");
                        PlayerA.系统提示("获胜者获得对方5W武勋!失败掉5W武勋!", 10, "复仇规则");
                        PlayerA.系统提示("失败惩罚减少打怪获得经验" + double.Parse(World.fc[6]) * 100 + "%", 10, "复仇规则");
                    }
                    else if (this.PlayerB == null)
                    {
                        this.PlayerB = current;
                        this.PlayerB.FC分数 = 0;
                        PlayerB.系统提示("复仇期间不能使用回城符、土灵符、追杀和传送命令等功能!", 10, "复仇规则");
                        PlayerB.系统提示("超出范围扣除一分!达到负10分则为输!复仇起间下线也算输!", 10, "复仇规则");
                        PlayerB.系统提示("此地图死亡掉落5000武勋,对方获得5000武勋!", 10, "复仇规则");
                        PlayerB.系统提示("反之谁先获得10分谁获胜!杀死对方10次!", 10, "复仇规则");
                        PlayerB.系统提示("获胜者获得对方5W武勋!失败掉5W武勋!", 10, "复仇规则");
                        PlayerB.系统提示("失败惩罚减少打怪获得经验" + double.Parse(World.fc[6]) * 100 + "%", 10, "复仇规则");
                    }
                }
                this.MapID = int.Parse(World.fc[0]);
                this.PVPName = "复仇区";
                World.复仇进程 = 2;
                this.时间1 = new System.Timers.Timer(60000.0);
                this.时间1.Elapsed += new ElapsedEventHandler(this.时间结束事件1);
                this.时间1.Enabled = true;
                this.时间1.AutoReset = true;
                this.时间结束事件1(null, null);
            }
            catch (Exception arg)
            {
                Form1.WriteLine(1, "FC EveClass 出错：" + arg);
            }
        }

        public void 时间结束事件1(object source, ElapsedEventArgs e)
        {
            try
            {
                int num = (int)this.kssj.Subtract(DateTime.Now).TotalSeconds;
                ////if (num <= 0)
                ////{
                ////    if (this.PVPType == 80)
                ////    {
                ////        World.Eve80进程 = 2;
                ////    }
                ////    else if (this.PVPType == 90)
                ////    {
                ////        World.Eve90进程 = 2;
                ////    }
                ////    num = 0;
                ////}
                this.kssjint = num;
                foreach (Players current in World.allConnectedChars.Values)
                {
                    current.系统提示(string.Concat(new object[]
                    {
                        "[",
                        this.PlayerA.UserName,
                        "] 和 [",
                        this.PlayerB.UserName,
                        "]即将在",
                        this.PVPName,
                        "场复仇,",
                        this.kssjint,
                        "秒后计分。"
                    }), 19, this.PVPName);

                }
                if (this.kssjint <= 0)
                {
                    foreach (Players current2 in this.playlist.Values)
                    {
                        if (!current2.检查玩家是否在复仇区内(current2))
                        {
                            current2.移动(float.Parse(World.fc[1]), float.Parse(World.fc[2]), 15f, int.Parse(World.fc[0]));

                        }
                        current2.系统公告("开始计分...");
                    }
                    this.时间1.Enabled = false;
                    this.时间1.Close();
                    this.时间1.Dispose();
                    World.复仇进程 = 3;
                    this.kssjgj = DateTime.Now.AddMinutes(10.0);
                    this.时间2 = new System.Timers.Timer(10000.0);
                    this.时间2.Elapsed += new ElapsedEventHandler(this.时间结束事件2);
                    this.时间2.Enabled = true;
                    this.时间2.AutoReset = true;
                    this.时间5 = new System.Timers.Timer(3000.0);
                    this.时间5.Elapsed += new ElapsedEventHandler(this.时间结束事件5);
                    this.时间5.Enabled = true;
                    this.时间5.AutoReset = true;
                }
            }
            catch (Exception arg)
            {
                Form1.WriteLine(1, "PVP 时间结束事件1 出错：" + arg);
            }
        }

        public void 时间结束事件2(object source, ElapsedEventArgs e)
        {
            try
            {
                int num = (int)this.kssjgj.Subtract(DateTime.Now).TotalSeconds;
                foreach (Players current in this.playlist.Values)
                {
                    current.系统提示(string.Concat(new object[]
                    {
                        this.PlayerA.UserName,
                        "->[",
                        this.PlayerA.FC分数,
                        "] VS ",
                        this.PlayerB.UserName,
                        "->[",
                        this.PlayerB.FC分数,
                        "] 复仇结束倒计时",
                        num,
                        "秒。"
                    }), 19, this.PVPName);
                }
                if (num <= 0)
                {
                    World.复仇进程 = 6;
                    this.时间2.Enabled = false;
                    this.时间2.Close();
                    this.时间2.Dispose();
                    this.时间5.Enabled = false;
                    this.时间5.Close();
                    this.时间5.Dispose();
                    this.时间3 = new System.Timers.Timer(10000.0);
                    this.时间3.Elapsed += new ElapsedEventHandler(this.时间结束事件3);
                    this.时间3.Enabled = true;
                    this.时间3.AutoReset = false;
                }
            }
            catch (Exception arg)
            {
                Form1.WriteLine(1, "PVP 时间结束事件2 出错：" + arg);
            }
        }

        public void 时间结束事件3(object source, ElapsedEventArgs e)
        {
            try
            {
                //int num = (int)((double)(World.进场最低费用 * 2) * (1.0 - World.场地佣金百分比));
                if (!this.PlayerA.Client.Running && !this.PlayerB.Client.Running)
                {
                    foreach (Players current in World.allConnectedChars.Values)
                    {
                        current.系统提示("复仇时间到！由于双方中场退出,复仇比赛结束。", 19, this.PVPName);
                    }
                    this.Dispose();
                }
                else if (!this.PlayerA.Client.Running)
                {
                    foreach (Players current2 in World.allConnectedChars.Values)
                    {
                        current2.系统提示(string.Concat(new string[]
                        {
                            "复仇时间到！由于[",
                            this.PlayerA.UserName,
                            "]中场退出,[",
                            this.PlayerB.UserName,
                            "]获胜,复仇比赛结束。"
                        }), 19, this.PVPName);
                    }
                    Dispose();
                }
                else if (!this.PlayerB.Client.Running)
                {
                    foreach (Players current3 in World.allConnectedChars.Values)
                    {
                        current3.系统提示(string.Concat(new string[]
                        {
                            "复仇时间到！由于[",
                            this.PlayerB.UserName,
                            "]中场退出,[",
                            this.PlayerA.UserName,
                            "]获胜,复仇比赛结束。"
                        }), 19, this.PVPName);
                    }
                    Dispose();

                }
                else if (this.PlayerA.FC分数 == this.PlayerB.FC分数)
                {
                    foreach (Players current4 in World.allConnectedChars.Values)
                    {
                        current4.系统提示("复仇时间到,双方没有在时间内分出胜负,比分相等.均不受到惩罚。", 19, this.PVPName);
                    }
                    Dispose();

                }
                else if (this.PlayerA.FC分数 > this.PlayerB.FC分数)
                {
                    //this.PlayerA.查百宝阁元宝数();
                    //this.PlayerA.检察元宝数据(num, 1);
                    //this.PlayerA.保存元宝数据();
                    //RxjhClass.百宝记录(this.PlayerA.Userid, this.PlayerA.UserName, 0L, "复仇胜利获得", 1, num);
                    foreach (Players current4 in World.allConnectedChars.Values)
                    {
                        current4.系统提示(string.Concat(new object[]
                        {
                            "复仇时间到,[",
                            this.PlayerA.UserName,
                            "][",
                            this.PlayerA.FC分数,
                            "] VS [",
                            this.PlayerB.UserName,
                            "][",
                            this.PlayerB.FC分数,
                            "] 。"
                        }), 19, this.PVPName);
                        current4.系统提示("[" + this.PlayerA.UserName + "]获胜,复仇比赛结束。", 19, this.PVPName);
                    }
                    int num2 = 60000 * int.Parse(World.fc[5]);//时间
                    if (PlayerB.追加状态列表.ContainsKey(int.Parse(World.fc[4])))
                    {
                        追加状态类 追加状态类 = PlayerB.追加状态列表[int.Parse(World.fc[4])];
                        //num2 += 追加状态类.FLD_sj;
                        追加状态类.时间结束事件();
                    }
                    if (PlayerB.追加状态列表.ContainsKey(int.Parse(World.dt[4])))
                    {
                        追加状态类 追加状态类 = PlayerB.追加状态列表[int.Parse(World.dt[4])];
                        //num2 += 追加状态类.FLD_sj;
                        追加状态类.时间结束事件();
                    }
                    追加状态类 追加状态类2 = new 追加状态类(PlayerB, num2, int.Parse(World.fc[4]), 1);
                    PlayerB.追加状态列表.Add(追加状态类2.FLD_PID, 追加状态类2);
                    PlayerB.FLD_人物_复仇_经验百分比 = double.Parse(World.fc[6]);
                    PlayerB.状态效果(BitConverter.GetBytes(int.Parse(World.fc[4])), 1, num2);
                    bool 是否满足 = false;
                    if (PlayerB.Player_WuXun >= 50000)
                    {
                        是否满足 = true;
                        PlayerB.Player_WuXun -= 50000;
                        PlayerA.Player_WuXun += 50000;
                        PlayerA.更新武功和状态();
                        //PlayerA.保存人物的数据();
                        PlayerA.系统提示("获胜获得5W武勋, 复仇成功。", 19, this.PVPName);
                        PlayerB.系统提示("战败获得惩罚打怪获得经验降低" + double.Parse(World.fc[6]) * 100 + " %减少5W武勋, 复仇比赛结束。", 19, this.PVPName);
                    }
                    PlayerB.复仇更新人物减经验();
                    PlayerB.更新武功和状态();
                    //PlayerB.保存人物的数据();
                    if (!是否满足)
                    {
                        PlayerB.系统提示("战败获得惩罚打怪获得经验降低" + double.Parse(World.fc[6]) * 100 + " %, 复仇比赛结束。", 19, this.PVPName);
                    }
                    Dispose();

                }
                else if (this.PlayerA.FC分数 < this.PlayerB.FC分数)
                {
                    //this.PlayerA.查百宝阁元宝数();
                    //this.PlayerA.检察元宝数据(num, 1);
                    //this.PlayerA.保存元宝数据();
                    //RxjhClass.百宝记录(this.PlayerA.Userid, this.PlayerA.UserName, 0L, "复仇胜利获得", 1, num);
                    foreach (Players current4 in World.allConnectedChars.Values)
                    {
                        current4.系统提示(string.Concat(new object[]
                        {
                            "复仇时间到,[",
                            this.PlayerA.UserName,
                            "][",
                            this.PlayerA.FC分数,
                            "] VS [",
                            this.PlayerB.UserName,
                            "][",
                            this.PlayerB.FC分数,
                            "] 。"
                        }), 19, this.PVPName);
                        current4.系统提示("[" + this.PlayerB.UserName + "]获胜,复仇比赛结束。", 19, this.PVPName);
                    }
                    int num2 = 60000 * int.Parse(World.fc[5]);//时间
                    if (PlayerA.追加状态列表.ContainsKey(int.Parse(World.fc[4])))
                    {
                        追加状态类 追加状态类 = PlayerA.追加状态列表[int.Parse(World.fc[4])];
                        //num2 += 追加状态类.FLD_sj;
                        追加状态类.时间结束事件();
                    }
                    if (PlayerA.追加状态列表.ContainsKey(int.Parse(World.dt[4])))
                    {
                        追加状态类 追加状态类 = PlayerA.追加状态列表[int.Parse(World.dt[4])];
                        //num2 += 追加状态类.FLD_sj;
                        追加状态类.时间结束事件();
                    }
                    追加状态类 追加状态类2 = new 追加状态类(PlayerA, num2, int.Parse(World.fc[4]), 1);
                    PlayerA.追加状态列表.Add(追加状态类2.FLD_PID, 追加状态类2);
                    PlayerA.FLD_人物_复仇_经验百分比 = double.Parse(World.fc[6]);
                    PlayerA.状态效果(BitConverter.GetBytes(int.Parse(World.fc[4])), 1, num2);
                    PlayerA.复仇更新人物减经验();
                    bool 是否满足 = false;
                    if (PlayerA.Player_WuXun >= 50000)
                    {
                        是否满足 = true;
                        PlayerA.Player_WuXun -= 50000;
                        PlayerB.Player_WuXun += 50000;
                        PlayerB.更新武功和状态();
                        //PlayerB.保存人物的数据();
                        PlayerB.系统提示("获胜获得5W武勋, 复仇成功。", 19, this.PVPName);
                        PlayerA.系统提示("战败获得惩罚打怪获得经验降低" + double.Parse(World.fc[6]) * 100 + " %减少5W武勋, 复仇比赛结束。", 19, this.PVPName);
                    }
                    PlayerA.更新武功和状态();
                    //PlayerA.保存人物的数据();
                    if (!是否满足)
                    {
                        PlayerA.系统提示("战败获得惩罚打怪获得经验降低" + double.Parse(World.fc[6]) * 100 + " %, 复仇比赛结束。", 19, this.PVPName);
                    }
                    Dispose();

                }

                World.复仇进程 = 5;
                this.kssjgj = DateTime.Now.AddMinutes(1.0);
                this.时间3.Enabled = false;
                this.时间3.Close();
                this.时间3.Dispose();
                this.时间4 = new System.Timers.Timer(30000.0);
                this.时间4.Elapsed += new ElapsedEventHandler(this.时间结束事件4);
                this.时间4.Enabled = true;
                this.时间4.AutoReset = true;
                this.时间5.Enabled = false;
                this.时间5.Close();
                this.时间5.Dispose();
            }
            catch (Exception arg)
            {
                this.Dispose();
                Form1.WriteLine(1, "PVP 时间结束事件3 出错：" + arg);
            }
        }
        public void 时间结束事件4(object source, ElapsedEventArgs e)
        {
            try
            {
                int num = (int)this.kssjgj.Subtract(DateTime.Now).TotalSeconds;
                if (num <= 0)
                {
                    this.时间4.Enabled = false;
                    this.时间4.Close();
                    this.时间4.Dispose();
                    World.复仇进程 = 4;
                    this.Dispose();
                }
            }
            catch (Exception arg)
            {
                this.Dispose();
                Form1.WriteLine(1, "PVP 时间结束事件4 出错：" + arg);
            }
        }
        public void 时间结束事件5(object source, ElapsedEventArgs e)
        {
            try
            {
                foreach (Players current in this.playlist.Values)
                {
                    if (current.人物PK模式 != 2)
                    {
                        current.切换PK模式(2);
                    }
                    if (!current.检查玩家是否在复仇区内(current))
                    {
                        current.移动(float.Parse(World.fc[1]), float.Parse(World.fc[2]), 15f, int.Parse(World.fc[0]));
                        //if (current.FC分数 >= 0)
                        //{
                            current.FC分数--;
                            current.系统提示("你已累计逃跑一次,扣除一分。累计负10分后,视为输!", 19, "系統警告");
                        //}
                        break;

                    }
                    else
                    {
                        if (current.FC分数 <= -5)
                        {
                            if (current == PlayerA && PlayerA != null)
                            {

                                int num2 = 60000 * int.Parse(World.fc[5]);//时间
                                if (PlayerA.追加状态列表.ContainsKey(int.Parse(World.fc[4])))
                                {
                                    追加状态类 追加状态类 = PlayerA.追加状态列表[int.Parse(World.fc[4])];
                                    //num2 += 追加状态类.FLD_sj;
                                    追加状态类.时间结束事件();
                                }
                                if (PlayerA.追加状态列表.ContainsKey(int.Parse(World.dt[4])))
                                {
                                    追加状态类 追加状态类 = PlayerA.追加状态列表[int.Parse(World.dt[4])];
                                    //num2 += 追加状态类.FLD_sj;
                                    追加状态类.时间结束事件();
                                }
                                追加状态类 追加状态类2 = new 追加状态类(PlayerA, num2, int.Parse(World.fc[4]), 1);
                                PlayerA.追加状态列表.Add(追加状态类2.FLD_PID, 追加状态类2);
                                PlayerA.FLD_人物_复仇_经验百分比 = double.Parse(World.fc[6]);
                                PlayerA.状态效果(BitConverter.GetBytes(int.Parse(World.fc[4])), 1, num2);
                                bool 是否满足 = false;
                                if (PlayerA.Player_WuXun >= 50000)
                                {
                                    是否满足 = true;
                                    PlayerA.Player_WuXun -= 50000;
                                    PlayerB.Player_WuXun += 50000;
                                    PlayerB.更新武功和状态();
                                    //PlayerB.保存人物的数据();
                                    PlayerB.系统提示("获胜获得5W武勋, 复仇成功。", 19, this.PVPName);
                                    PlayerA.系统提示("累计逃跑次数10次,打怪获得经验降低" + double.Parse(World.fc[6]) * 100 + " %减少5w武勋, 复仇失败。", 19, this.PVPName);
                                }
                                PlayerA.复仇更新人物减经验();
                                PlayerA.更新武功和状态();
                                //PlayerA.保存人物的数据();
                                if (!是否满足)
                                {
                                    PlayerA.系统提示("累计逃跑次数10次,打怪获得经验降低" + double.Parse(World.fc[6]) * 100 + " %, 复仇失败。", 19, this.PVPName);
                                }
               
                                World.conn.发送("全服公告|6|系统提示|复仇结束[" + this.PlayerB.UserName + "]获胜,复仇比赛结束。");
                                Dispose();
                               
                            }
                            else if (current == PlayerB && PlayerB != null)
                            {

                                int num2 = 60000 * int.Parse(World.fc[5]);//时间
                                if (PlayerB.追加状态列表.ContainsKey(int.Parse(World.fc[4])))
                                {
                                    追加状态类 追加状态类 = PlayerB.追加状态列表[int.Parse(World.fc[4])];
                                    //num2 += 追加状态类.FLD_sj;
                                    追加状态类.时间结束事件();
                                }
                                if (PlayerB.追加状态列表.ContainsKey(int.Parse(World.dt[4])))
                                {
                                    追加状态类 追加状态类 = PlayerB.追加状态列表[int.Parse(World.dt[4])];
                                    //num2 += 追加状态类.FLD_sj;
                                    追加状态类.时间结束事件();
                                }
                                追加状态类 追加状态类2 = new 追加状态类(PlayerB, num2, int.Parse(World.fc[4]), 1);
                                PlayerB.追加状态列表.Add(追加状态类2.FLD_PID, 追加状态类2);
                                PlayerB.FLD_人物_复仇_经验百分比 = double.Parse(World.fc[6]);
                                PlayerB.状态效果(BitConverter.GetBytes(int.Parse(World.fc[4])), 1, num2);
                                bool 是否满足 = false;
                                if (PlayerB.Player_WuXun >= 50000)
                                {
                                    是否满足 = true;
                                    PlayerB.Player_WuXun -= 50000;
                                    PlayerA.Player_WuXun += 50000;
                                    PlayerA.更新武功和状态();
                                    //PlayerA.保存人物的数据();
                                    PlayerA.系统提示("获胜获得5W武勋, 复仇成功。", 19, this.PVPName);
                                    PlayerB.系统提示("累计逃跑次数10次,打怪获得经验降低" + double.Parse(World.fc[6]) * 100 + " %减少5W武勋, 复仇失败。", 19, this.PVPName);
                                }
                                PlayerB.复仇更新人物减经验();
                                PlayerB.更新武功和状态();
                                //PlayerB.保存人物的数据();
                                if (!是否满足)
                                {
                                    PlayerB.系统提示("累计逃跑次数10次,打怪获得经验降低" + double.Parse(World.fc[6]) * 100 + " %, 复仇失败。", 19, this.PVPName);
                                }
         
                                World.conn.发送("全服公告|6|系统提示|复仇结束[" + this.PlayerA.UserName + "]获胜,复仇比赛结束。");
                                Dispose();
                            }

                            break;

                        }

                    }
                }

                //foreach (Players current2 in World.allConnectedChars.Values)
                //{
                //    if (current2.人物坐标_地图 == this.MapID && current2.人物全服ID != this.PlayerA.人物全服ID && current2.人物全服ID != this.PlayerB.人物全服ID)
                //    {

                //        current2.移动(529f, 1528f, 15f, 101);
                //    }
                //}
            }
            catch (Exception arg)
            {
                this.Dispose();
                Form1.WriteLine(1, "PVP 时间结束事件6 出错：" + arg);
            }
        }

        public void Dispose()
        {
            try
            {
                if (this.时间1 != null)
                {
                    this.时间1.Enabled = false;
                    this.时间1.Close();
                    this.时间1.Dispose();
                }
                if (this.时间2 != null)
                {
                    this.时间2.Enabled = false;
                    this.时间2.Close();
                    this.时间2.Dispose();
                }
                if (this.时间3 != null)
                {
                    this.时间3.Enabled = false;
                    this.时间3.Close();
                    this.时间3.Dispose();
                }
                if (this.时间4 != null)
                {
                    this.时间4.Enabled = false;
                    this.时间4.Close();
                    this.时间4.Dispose();
                }
                if (this.时间5 != null)
                {
                    this.时间5.Enabled = false;
                    this.时间5.Close();
                    this.时间5.Dispose();
                }
                foreach (Players current in this.playlist.Values)
                {
                    current.FC分数 = 0;
                    current.移动(529f, 1528f, 15f, 101);
                    current.切换PK模式(0);
                }
                this.PlayerA = null;
                this.PlayerB = null;
                this.playlist.Clear();
                World.eve80Players.Clear();
            }
            catch
            {
                this.PlayerA = null;
                this.PlayerB = null;
                World.eve80Players.Clear();
                this.playlist.Clear();
            }
            finally
            {
                this.PlayerA = null;
                this.PlayerB = null;
                World.eve80Players.Clear();
                this.playlist.Clear();
            }
            World.复仇 = null;
            World.复仇进程 = 0;


        }
    }
}
